package com.hdy.web.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MyMvcConfig implements WebMvcConfigurer {
   @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/signin").setViewName( "index");
        registry.addViewController("/signup").setViewName( "register");
       registry.addViewController("/main").setViewName( "main");
       registry.addViewController("/list").setViewName( "list");
       registry.addViewController("/insert").setViewName( "add");
       registry.addViewController("/error").setViewName( "404");
       //registry.addViewController("/getQ").setViewName( "plaza");
       registry.addViewController("/ask").setViewName( "ask");
       registry.addViewController("/reply").setViewName( "reply");
       registry.addViewController("/reply2").setViewName( "reply2");
       registry.addViewController("/details").setViewName( "details");
       registry.addViewController("/lookupGoods").setViewName( "lookupGoods");
       registry.addViewController("/insertGoods").setViewName( "insertGoods");
       registry.addViewController("/deleteGoods").setViewName( "deleteGoods");
       registry.addViewController("/export").setViewName( "export");

}
//自定义国际化组件
    @Bean
    public LocaleResolver localeResolver(){
        return new MyLocaleResolver();
    }
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginHandlerInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns("/signin","/signup","/user/login","/user/signup","/css/*","/img/**","/js/**");
    }
}

